<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head th:replace="component/head :: head">
</head>
<body>

	<div class="container">
		<input type="text" class="form-control" id="title"
			aria-describedby="basic-addon3">
		<button onclick="getBlogByTitle()" type="button"
			class="btn btn-primary">查询</button>
		<button onclick="refreshBlogCache()" class="btn btn-secondary"
			role="button" id="academy-classes-dm-detail-url">刷新缓存</button>
	</div>

	<script type="text/javascript">
		function getBlogByTitle() {
			var title = $('#title').val();
			if (title == "" || title == null) {
				alert("请输入博客标题");
				return;
			}
			$.ajax({
				url : "/patterns/restblog/get-blogvo-by-title",
				type : "POST",
				contentType : "application/json; charset=utf-8",
				data : title,
				dataType : 'json',
				async : true,
				success : function(result) {
					if (result.success == false) {
						if (result.code == 9002) {
							alert("参数错误");
						} else if (result.code == 9999) {
							alert("系统错误");
						} else if (result.code == 1005) {
							alert("无该博客");
						}
					} else {
						if (result.code == 1007) {
							alert("从缓存中查到!");
						} else if (result.code == 1008) {
							alert("从数据库中查到!");
						}
					}
				},
				error : function(e) {
					alert("异常");
				}
			});
		}

		function refreshBlogCache() {
			var title = $('#title').val();
			if (title == "" || title == null) {
				alert("请输入博客标题");
				return;
			}
			$.ajax({
				url : "/patterns/restblog/refresh-blog-cache",
				type : "POST",
				contentType : "application/json; charset=utf-8",
				data : title,
				dataType : 'json',
				async : true,
				success : function(result) {
					if (result.success == false) {
						if (result.code == 9002) {
							alert("参数错误");
						} else if (result.code == 9999) {
							alert("系统错误");
						} else if (result.code == 1005) {
							alert("无该博客");
						}
					} else {
						alert("刷新缓存成功！");
					}
				},
				error : function(e) {
					alert("异常");
				}
			});
		}
	</script>

	<footer th:replace="component/footer :: footer"></footer>
	<div th:replace="component/footer-lib"></div>
</body>

</html>